package com.topnav.mc.test;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.js.lib.annotation.ApiLogger;
import com.js.lib.result.Result;
import com.topnav.mc.listener.bean.DeviceAlarmMessage;
import com.topnav.mc.listener.bean.GPSMsgInfo;
import com.topnav.mc.validator.group.IAdd;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.topnav.mc.uitls.RedisUtil;
/**
 * 模拟报警
 * @Author: kenny
 * @Date: 2023/11/7 16:05
 */
@RestController
@CrossOrigin
@RequestMapping("test/simulate/")
public class SimulateAlarmController {

    /**
     * SOS 报警测试
     * @param data
     * @return
     */
    @PostMapping("alarm/post")
    @ResponseBody
    public Result alarmPost(@RequestBody DeviceAlarmMessage data) {
        String key = "device_sos_alarm";
        // (JSONObject) JSON.toJSON(data);
        RedisUtil.publish("device_sos_alarm",(JSONObject) JSON.toJSON(data));

        return Result.ok();
    }


    /**
     * 模拟GPS测试
     * @param data
     * @return
     */
    @PostMapping("gps/post")
    @ResponseBody
    public Result gpsPost(@RequestBody GPSMsgInfo data) {
        String key = "mobileposition";
        // (JSONObject) JSON.toJSON(data);
        RedisUtil.publish(key,(JSONObject) JSON.toJSON(data));

        return Result.ok();
    }

}
